package com.twu.biblioteca.ui.menus.items.books;

import com.twu.biblioteca.library.Library;
import com.twu.biblioteca.ui.menus.AbstractMenu;
import com.twu.biblioteca.ui.menus.books.CheckoutBookMenu;
import com.twu.biblioteca.ui.menus.items.AbstractMenuItem;
import com.twu.biblioteca.users.UserAccountsManager;

/**
 * @author Alvi Jonathan Sait
 */
public class CheckoutBookMenuItem extends AbstractMenuItem {

    public CheckoutBookMenuItem() {
        super("Checkout a book");
    }

    @Override
    public AbstractMenu handleAction(Library library) {
        return new CheckoutBookMenu(library);
    }

    /**
     * This menu item is only available if there is a login user.
     */
    @Override
    public boolean isViewableByActiveUser(UserAccountsManager userAccountsManager) {
        return userAccountsManager.getCurrentlyActiveUser().isPresent();
    }
}
